# trace generated using paraview version 5.10.0
#
from paraview.simple import *
#working_dir = "/media/hpc/Backup_lwt/3DModel/G478-speedtest-Eikonal-decoded"
working_dir="/home/hpc/program/IDEALS3D/Share/G47800/Model/DDPM-0.15-50000epoch/Generate/C平台减面装药_epoch30000c5w0.5/Opt1"
id = "27#N2L4669M19"

# import the simple module from the paraview

ImportPresets(filename='DEAD/AutoDecoder/ParaviewMacro/All_idl_cmaps.xml')
ImportPresets(filename='DEAD/AutoDecoder/ParaviewMacro/All_mpl_cmaps.xml')

# create a new 'XML Structured Grid Reader'
target_vts = XMLStructuredGridReader(
    FileName=[working_dir+"/"+id+".vts"])

# get active view
renderView1 = GetActiveViewOrCreate('RenderView')

# show data in view
target_vtsDisplay = Show(target_vts, renderView1)

# trace defaults for the display properties.
target_vtsDisplay.Representation = 'Outline'

# reset view to fit data
renderView1.ResetCamera()

# update the view to ensure updated data information
renderView1.Update()

# hide data in view
Hide(target_vts, renderView1)

# create a new 'Iso Volume'
isoVolume1 = IsoVolume(Input=target_vts)

# Properties modified on isoVolume1
isoVolume1.InputScalars = ['POINTS', 'define_marker_rho']
isoVolume1.ThresholdRange = [0, 50.0]

# show data in view
isoVolume1Display = Show(isoVolume1, renderView1)

# trace defaults for the display properties.
isoVolume1Display.Representation = 'Surface'

# hide data in view
Hide(isoVolume1, renderView1)

# create a new 'Iso Volume'
isoVolume2 = IsoVolume(Input=isoVolume1)

# Properties modified on isoVolume1
isoVolume2.InputScalars = ['POINTS', 'define_marker_theta']
isoVolume2.ThresholdRange = [0, 50.0]

# show data in view
isoVolume2Display = Show(isoVolume2, renderView1)

# trace defaults for the display properties.
isoVolume2Display.Representation = 'Surface'

# hide data in view
Hide(isoVolume2, renderView1)


# create a new 'Contour'
contour1 = Contour(Input=isoVolume2)

# Properties modified on contour1
contour1.Isosurfaces = [-0.002]
contour1.ComputeNormals = 1
contour1.GenerateTriangles = 0

# show data in view
contour1Display = Show(contour1, renderView1)

# trace defaults for the display properties.
contour1Display.Representation = 'Surface'

# turn off scalar coloring
ColorBy(contour1Display, None)

# update the view to ensure updated data information
renderView1.Update()

# change solid color
contour1Display.DiffuseColor = [1.0, 0.0, 0.0]

# set active source
SetActiveSource(isoVolume2)

# create a new 'Iso Volume'
isoVolume3 = IsoVolume(Input=isoVolume2)

# Properties modified on isoVolume3
isoVolume3.ThresholdRange = [0.0, 50.0]

# show data in view
isoVolume3Display = Show(isoVolume3, renderView1)

# trace defaults for the display properties.
isoVolume3Display.Representation = 'Surface'

# hide data in view
Hide(isoVolume1, renderView1)

# show color bar/color legend
isoVolume3Display.SetScalarBarVisibility(renderView1, False)

# update the view to ensure updated data information
renderView1.Update()

# turn off scalar coloring
ColorBy(isoVolume3Display, None)

# reset view to fit data
renderView1.ResetCamera()

# current camera placement for renderView1
renderView1.CameraPosition = [-2, -2, -2]
renderView1.CameraViewUp = [0.0, 1.0, 0.0]

renderView1.ResetCamera()

# Properties modified on renderView1
renderView1.OrientationAxesVisibility = 0

# set scalar coloring
ColorBy(isoVolume3Display, ('POINTS', 'u'))

# rescale color and/or opacity maps used to include current data range
isoVolume3Display.RescaleTransferFunctionToDataRange(True, False)

# show color bar/color legend
isoVolume3Display.SetScalarBarVisibility(renderView1, True)

# get color transfer function/color map for 'u'
uLUT = GetColorTransferFunction('u')

# get opacity transfer function/opacity map for 'u'
uPWF = GetOpacityTransferFunction('u')

# Apply a preset using its name. Note this may not work as expected when presets have duplicate names.
uLUT.ApplyPreset('flag', True)

# rescale color and/or opacity maps used to exactly fit the current data range
isoVolume3Display.RescaleTransferFunctionToDataRange(True, True)

print("finish: "+id)

# Stay
Interact()
